package cn.jkgly.test.Controller;

import cn.jkgly.test.pojo.JSONResult;
import cn.jkgly.test.pojo.Resource;
import cn.jkgly.test.pojo.User;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class HelloController {

    @Autowired
    private Resource resource;

    @RequestMapping("/getResource")
    public JSONResult getResource() {
        Resource bean=new Resource();
        BeanUtils.copyProperties(resource,bean);
        return JSONResult.ok(bean);
    }

    @RequestMapping("/hello")
    public Object hello() {
        return "hello~";
    }


    @RequestMapping("/hello2")
    public Object hello2() {
        User u = new User();
        u.setAge(12);
        u.setBrithday(new Date());
        u.setDesc("");
        u.setName("张aaa三");
        u.setPassword("密码");
        return u;
    }
}
